{include file="header.html"}
<body class="gr">

<div class="navBar">
	<a class="left" href="wap.php?app=member&act=order"><i class="return"></i></a>
	<div class="titleView-x">订单详情</div>
</div>

<div class="member-order-detail main-top">
	<div class="order-sn">订单号：{$data->order_sn}<span class="status status{$data->status}">{if $data->status==0}待支付{elseif $data->status==1}已支付{elseif $data->status==2}已完成{elseif $data->status==-1}已取消{/if}</span></div>
	<div class="tip">费用明细</div>
	<ul class="groupView">
		<li class="ge-bottom"><div>参保人</div><span class="name">{$data->name}</span></li>
		<li class="ge-bottom"><div>身份证号</div><span class="idcard">{$data->idcard}</span></li>
		<li class="ge-bottom"><div>参保城市</div><span class="city">{$data->province_name} {$data->city_name}</span></li>
		<li class="ge-bottom"><div>参保月份</div><span class="month">{if is_array($data->months)}{if count($data->months)==1}{$data->months[0]}{else}{$data->months[0]} - {$data->months[count($data->months)-1]}{/if}{else}-{/if}</span></li>
		<li class="ge-bottom"><div>社保费用</div><span class="">{$data->total_price-$data->gjj_total-$data->gjj_service_money_total-$data->service_money_total}元</span></li>
		<li class="ge-bottom"><div>公积金费用</div><span class="">{$data->gjj_total}元</span></li>
		<li class="ge-bottom"><div>服务费</div><span class="">{$data->service_money_total+$data->gjj_service_money_total}元</span></li>
		<!--<li class="ge-bottom"><div>其他费用</div><span class=""></span></li>-->
	</ul>
	<div class="total-price"><font>¥{$data->total_price}元</font><span>合计费用：</span></div>

	<div class="tip2 tip">支付方式</div>
	<div class="wxpay">微信支付</div>

	{if $data->status==0}
	<div class="buttonView">
		<a class="pay btn" href="javascript:callApi()">立即付款</a>
	</div>
	{/if}
	{if $data->status==1}
	<div class="buttonView">
		{if $data->differ_money>0}<a class="differ" href="javascript:callApi()">补差价</a>{/if}
		<a class="refund {if $data->ask_refund_time>0}disabled{/if}" href="javascript:void(0)">申请退款</a>
		{if $data->member_mobile==1}
		<a class="renew btn" href="javascript:void(0)">我要续费</a>
		{else}
		<a class="btn" onclick="mobile()">我要续费</a>
		{/if}
	</div>
	{/if}
	{if $data->status==-1}
	<div class="buttonView">
		<a class="renew btn" href="javascript:void(0)">重新下单</a>
	</div>
	{/if}
</div>

{include file="footer.html"}
<link type="text/css" href="/css/alertUI.css" rel="stylesheet">
<script>
function mobile() {
	alert('请先到首页点击购买社保绑定手机号码');
    location.href = 'wap.php?app=home&act=index';
}

{if $data->status==0 || $data->differ_money>0}
//调用微信JS api 支付
function jsApiCall(){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		{$jsApiParameters},
		function(res){
			console.log(res);
			if(res.err_msg=='get_brand_wcpay_request:ok'){
				{if $data->status==0}
				location.href = 'wap.php?app=cart&act=order_complete&order_sn={$data->order_sn}';
				{else}
				location.href = 'wap.php?tpl=cart.order_diff_complete&order_sn={$data->order_sn}';
				{/if}
			}else{
				//alert('支付失败， 原因：\n'+res.err_desc);
				$('.member-order-detail a.pay, .member-order-detail a.differ').html('重新支付');
			}
		}
	);
}

function callApi(){
	if (typeof WeixinJSBridge == "undefined"){
		if( document.addEventListener ){
			document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		}else if (document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady', jsApiCall);
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		}
	}else{
		jsApiCall();
	}
}
{/if}
$(function(){
	$('.renew').click(function(){
		if('{$data->province}'!='' && '{$data->city}'!='' && '{$data->casy_id}'!=''){
			location.href = 'wap.php?app=cart&act=info&renew=1&person_id={$data->person_id}&province_id={$data->province}&city_id={$data->city}&casy_id={$data->casy_id}';
		}
	});
	$('.refund:not(.disabled)').click(function(){
		alertUI({
			cls:'ios7-alert',
			html : '请问您确定要申请退款吗？',
			btns : [{
				text : ' 确定 ',
				click : function(){
					alertUI();
					$.postJSON('api.php?app=member&act=order_refund', { id:'{$data->id}' }, function(json){
						$('.refund').addClass('disabled');
						alertUI({
							cls:'ios7-alert',
							//html : '您好，我们已收到您的退款申请，请您留意“我的消息”或者“联系客服”，我们将尽快给您答复。谢谢。',
							html : '您好，我们已收到您的退款申请，我们将尽快为你处理。',
							btns : [{
								text : ' 确定 ',
								click : function(){
									alertUI();
								}
							}]
						});
					});
				}
			},{
				text : ' 取消 ',
				click : function(){ alertUI() }
			}]
		});
	});
});
</script>